package com.berry.MedCheck.widget;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.berry.MedCheck.R;

/**
 * Created with IntelliJ IDEA.
 * User: Airay.Rong
 * Date: 13-12-4
 * Time: 下午2:48
 * To change this template use File | Settings | File Templates.
 */
public class SettingItemWidget extends LinearLayout {
	private TextView mLabel;
	private TextView mText;
	private ImageView mArrow;

	public SettingItemWidget(Context context) {
		super(context);
	}

	public SettingItemWidget(Context context, AttributeSet attrs) {
		super(context, attrs);
		setOrientation(HORIZONTAL);
		TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.setting_item);
		CharSequence labelText = ta.getText(R.styleable.setting_item_setting_label);
		CharSequence textText = ta.getText(R.styleable.setting_item_setting_text);
		ta.recycle();
		LayoutInflater li = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		li.inflate(R.layout.setting_item,this,true);
		mLabel = (TextView) findViewById(R.id.label);
		mText = (TextView) findViewById(R.id.text);
		mArrow = (ImageView) findViewById(R.id.arrow);
		if (labelText != null) {
			setLabel(labelText);
		}
		if (textText != null) {
			mText.setText(textText);
		}
	}


	public void setLabel(CharSequence t){
		mLabel.setText(t);
	}
	public void setLabel (int resid){
		setLabel(getContext().getResources().getText(resid));
	}
	public void setText(CharSequence t){
		mText.setText(t);
	}
	public void setText(int id){
		setText(getContext().getResources().getText(id));
	}

	public ImageView getArrow() {
		return mArrow;
	}




}
